package DesignPattern.Composite;

/**
 * @Author self
 * @Date 2024/8/13 20:13
 */
import java.util.ArrayList;
import java.util.List;

public class Manager implements Employee {
    private String name;
    private String position;
    private List<Employee> subordinates;

    public Manager(String name, String position) {
        this.name = name;
        this.position = position;
        this.subordinates = new ArrayList<>();
    }

    public void addEmployee(Employee emp) {
        subordinates.add(emp);
    }

    public void removeEmployee(Employee emp) {
        subordinates.remove(emp);
    }

    @Override
    public void showEmployeeDetails() {
        System.out.println(name + " works as a " + position);
        for (Employee emp : subordinates) {
            emp.showEmployeeDetails();
        }
    }
}

